function action(){
/* penanganan form */
	if (isset($_POST['add'])) {
//	echo $this->input->post('jumlah');die();
		$bahan_masuk=array(
		'id_bahan'=>$this->input->post('nama_bahan'),
		'jumlah'=>$this->input->post('jumlah'));
//		$nama_bahan  = strip_tags($_POST['nama_bahan']);
//		$jumlah  	= strip_tags($_POST['jumlah']);
		
		//input ke db
		$this->bahan_masuk_model->save($bahan_masuk);
	} 
	else if (isset($_POST['Edit'])) {
		$nim  	= strip_tags($_POST['nim']);
		$nama  	= strip_tags($_POST['nama']);
		$alamat = strip_tags($_POST['alamat']);
		
		//update data
		$query = sprintf("UPDATE mahasiswa SET nama='%s', alamat='%s' WHERE nim='%s'", 
				mysql_escape_string($nama), 
				mysql_escape_string($alamat),
				mysql_escape_string($nim)
			);
		$sql = mysql_query($query);
	} 
	else if (isset($_POST['Delete'])) {
		$nim  	= strip_tags($_POST['nim']);
		
		//delete data
		$query = sprintf("DELETE FROM mahasiswa WHERE nim='%s'", 
				mysql_escape_string($nim)
			);
		$sql = mysql_query($query);
	} 
}
	function update($id){
	
	//set common properties
	$partial['_header']='template/header';
	$partial['_sidebar']="template/sidebar";
	$partial['_contents']="data_gudang/form_data_gudang";
	
	$data['title'] = 'Data Gudang';
	$data['action'] = site_url('data_gudang/update/'.$id.'/do');
	$data['form_attr'] = array('class' => 'form-horizontal', 'id' => 'FormGudang');
	$data['disable'] = 'disabled';		
	
	if(	$this->uri->segment(4) === false){
		$data['message']='';
		$data['gudang']=$this->data_gudang_model->get_by_id($id)->row_array();
		
		$this->load->model('satuan_model','',TRUE);
		$data['satuan']=$this->satuan_model->not($data['gudang']['id_satuan'])->result();
		
		$data['link_back']=anchor('data_gudang','Cancel',array('class'=>'back'));
		//load view
		$this->template->load('index',$partial,$data);
	}
	else{
		//save data
		$id=$this->input->post('id');
		$bahan=array('nama_bahan'=>$this->input->post('nama_bahan'),
		'jumlah'=>$this->input->post('jumlah'),
		'harga'=>$this->input->post('harga'),
		'id_satuan'=>$this->input->post('id_satuan'));
		$this->data_gudang_model->update($id,$bahan);
		//redirect to data list page
		redirect('data_gudang/index/3');			
		}
	}
	
	function delete($id){
	//delete data
	$this->data_gudang_model->delete($id);
	//redirect to data list page
	redirect('data_gudang/index/2');
	}
	}